package com.hqbzl.c1.rlock;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

@Slf4j
public class TestReentrantLock1 {
    final static ReentrantLock lock = new ReentrantLock();

    public static void main(String[] args) {
        m1();
    }

    public static void m1() {
        try {
            lock.lock();
            log.debug("m1");
            m2();
        } finally {
            lock.unlock();
        }
    }

    public static void m2() {
        try {
            lock.lock();
            log.debug("m2");
        } finally {
            lock.unlock();
        }

    }

}
